<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    
    <title>TCP BBR | jouyouyun&#39;s blog</title>
    <meta name="viewport" content="width=device-width,minimum-scale=1">
    <meta name="description" content="启用 BBR
BBR 是在 4.9 以后的内核才开始支持的, 可以试着执行 sudo modprobe tcp_bbr 来确定是否支持, 没有输出就意味着支持, 将下面两行内容添加到 /etc/sysctl.conf 文件里开启用它:
net.core.default_qdisc = fq
net.ipv4.tcp_congestion_control = bbr
使用 sysctl net.ipv4.tcp_available_congestion_control 查看支持的算法, 用 sysctl net.ipv4.tcp_congestion_control 查看当前使用的算法.
如果这个模块不会自动加载, 需要把 tcp_bbr_powered 添加到 /etc/modules-load.d/modules.conf 中.
另外测试发现, 有时 sysctl.conf 里的设置并不会应用, 需要手动执行一下, 因此便写了 reload-sysctl.service 来做这个, systemctl enable 这个服务后, 一切就 OK 了.">
    <meta name="generator" content="Hugo 0.105.0">
    
    
    
    
      <meta name="robots" content="noindex, nofollow">
    

    
<link rel="stylesheet" href="/ananke/css/main.min.css" >



    
    
    
      

    

    
    
    <meta property="og:title" content="TCP BBR" />
<meta property="og:description" content="启用 BBR
BBR 是在 4.9 以后的内核才开始支持的, 可以试着执行 sudo modprobe tcp_bbr 来确定是否支持, 没有输出就意味着支持, 将下面两行内容添加到 /etc/sysctl.conf 文件里开启用它:
net.core.default_qdisc = fq
net.ipv4.tcp_congestion_control = bbr
使用 sysctl net.ipv4.tcp_available_congestion_control 查看支持的算法, 用 sysctl net.ipv4.tcp_congestion_control 查看当前使用的算法.
如果这个模块不会自动加载, 需要把 tcp_bbr_powered 添加到 /etc/modules-load.d/modules.conf 中.
另外测试发现, 有时 sysctl.conf 里的设置并不会应用, 需要手动执行一下, 因此便写了 reload-sysctl.service 来做这个, systemctl enable 这个服务后, 一切就 OK 了." />
<meta property="og:type" content="article" />
<meta property="og:url" content="https://jouyouyun.github.io/post/tcp-bbr/" /><meta property="article:section" content="post" />
<meta property="article:published_time" content="2017-07-20T21:38:21+08:00" />
<meta property="article:modified_time" content="2019-11-27T19:42:57+08:00" />

<meta itemprop="name" content="TCP BBR">
<meta itemprop="description" content="启用 BBR
BBR 是在 4.9 以后的内核才开始支持的, 可以试着执行 sudo modprobe tcp_bbr 来确定是否支持, 没有输出就意味着支持, 将下面两行内容添加到 /etc/sysctl.conf 文件里开启用它:
net.core.default_qdisc = fq
net.ipv4.tcp_congestion_control = bbr
使用 sysctl net.ipv4.tcp_available_congestion_control 查看支持的算法, 用 sysctl net.ipv4.tcp_congestion_control 查看当前使用的算法.
如果这个模块不会自动加载, 需要把 tcp_bbr_powered 添加到 /etc/modules-load.d/modules.conf 中.
另外测试发现, 有时 sysctl.conf 里的设置并不会应用, 需要手动执行一下, 因此便写了 reload-sysctl.service 来做这个, systemctl enable 这个服务后, 一切就 OK 了."><meta itemprop="datePublished" content="2017-07-20T21:38:21+08:00" />
<meta itemprop="dateModified" content="2019-11-27T19:42:57+08:00" />
<meta itemprop="wordCount" content="230">
<meta itemprop="keywords" content="bbr," /><meta name="twitter:card" content="summary"/>
<meta name="twitter:title" content="TCP BBR"/>
<meta name="twitter:description" content="启用 BBR
BBR 是在 4.9 以后的内核才开始支持的, 可以试着执行 sudo modprobe tcp_bbr 来确定是否支持, 没有输出就意味着支持, 将下面两行内容添加到 /etc/sysctl.conf 文件里开启用它:
net.core.default_qdisc = fq
net.ipv4.tcp_congestion_control = bbr
使用 sysctl net.ipv4.tcp_available_congestion_control 查看支持的算法, 用 sysctl net.ipv4.tcp_congestion_control 查看当前使用的算法.
如果这个模块不会自动加载, 需要把 tcp_bbr_powered 添加到 /etc/modules-load.d/modules.conf 中.
另外测试发现, 有时 sysctl.conf 里的设置并不会应用, 需要手动执行一下, 因此便写了 reload-sysctl.service 来做这个, systemctl enable 这个服务后, 一切就 OK 了."/>

	
  </head>

  <body class="ma0 avenir bg-near-white">

    
   
  

  <header>
    <div class="bg-black">
      <nav class="pv3 ph3 ph4-ns" role="navigation">
  <div class="flex-l justify-between items-center center">
    <a href="/" class="f3 fw2 hover-white no-underline white-90 dib">
      
        jouyouyun&#39;s blog
      
    </a>
    <div class="flex-l items-center">
      

      
        <ul class="pl0 mr3">
          
          <li class="list f5 f4-ns fw4 dib pr3">
            <a class="hover-white no-underline white-90" href="/post/" title="Archives 页">
              Archives
            </a>
          </li>
          
          <li class="list f5 f4-ns fw4 dib pr3">
            <a class="hover-white no-underline white-90" href="/tags/" title="Tags 页">
              Tags
            </a>
          </li>
          
          <li class="list f5 f4-ns fw4 dib pr3">
            <a class="hover-white no-underline white-90" href="/categories/" title="Categories 页">
              Categories
            </a>
          </li>
          
        </ul>
      
      
<div class="ananke-socials">
  
    <a href="https://github.com/jouyouyun" target="_blank" class="github ananke-social-link link-transition stackoverflow link dib z-999 pt3 pt0-l mr1" title="GitHub link" rel="noopener" aria-label="follow on GitHub——Opens in a new window">
      
        <span class="icon"><svg style="enable-background:new 0 0 512 512;" version="1.1" viewBox="0 0 512 512"  xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" >
  <path d="M256,32C132.3,32,32,134.8,32,261.7c0,101.5,64.2,187.5,153.2,217.9c11.2,2.1,15.3-5,15.3-11.1   c0-5.5-0.2-19.9-0.3-39.1c-62.3,13.9-75.5-30.8-75.5-30.8c-10.2-26.5-24.9-33.6-24.9-33.6c-20.3-14.3,1.5-14,1.5-14   c22.5,1.6,34.3,23.7,34.3,23.7c20,35.1,52.4,25,65.2,19.1c2-14.8,7.8-25,14.2-30.7c-49.7-5.8-102-25.5-102-113.5   c0-25.1,8.7-45.6,23-61.6c-2.3-5.8-10-29.2,2.2-60.8c0,0,18.8-6.2,61.6,23.5c17.9-5.1,37-7.6,56.1-7.7c19,0.1,38.2,2.6,56.1,7.7   c42.8-29.7,61.5-23.5,61.5-23.5c12.2,31.6,4.5,55,2.2,60.8c14.3,16.1,23,36.6,23,61.6c0,88.2-52.4,107.6-102.3,113.3   c8,7.1,15.2,21.1,15.2,42.5c0,30.7-0.3,55.5-0.3,63c0,6.1,4,13.3,15.4,11C415.9,449.1,480,363.1,480,261.7   C480,134.8,379.7,32,256,32z"/>
</svg>
</span>
      
<span class="new-window"><svg  height="8px"  style="enable-background:new 0 0 1000 1000;" version="1.1" viewBox="0 0 1000 1000"  xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" >
<path d="M598 128h298v298h-86v-152l-418 418-60-60 418-418h-152v-86zM810 810v-298h86v298c0 46-40 86-86 86h-596c-48 0-86-40-86-86v-596c0-46 38-86 86-86h298v86h-298v596h596z" style="fill-rule:evenodd;clip-rule:evenodd;"/>
</svg>
</span></a>
  
</div>

    </div>
  </div>
</nav>

    </div>
  </header>



    <main class="pb7" role="main">
      
  
  <article class="flex-l flex-wrap justify-between mw8 center ph3">
    <header class="mt4 w-100">
      <aside class="instapaper_ignoref b helvetica tracked">
          
        POSTS
      </aside>
      










  <div id="sharing" class="mt3 ananke-socials">
    
  </div>


      <h1 class="f1 athelas mt3 mb1">TCP BBR</h1>
      
      <p class="tracked">
         <strong>jouyouyun</strong>
      </p>
      
      
      
      <time class="f6 mv4 dib tracked" datetime="2017-07-20T21:38:21+08:00">七月 20, 2017</time>
      

      
      
    </header>
    <div class="nested-copy-line-height lh-copy serif f4 nested-links mid-gray pr4-l w-two-thirds-l"><h2 id="启用-bbr">启用 BBR</h2>
<p><code>BBR</code> 是在 4.9 以后的内核才开始支持的, 可以试着执行 <code>sudo modprobe tcp_bbr</code> 来确定是否支持, 没有输出就意味着支持, 将下面两行内容添加到 <code>/etc/sysctl.conf</code> 文件里开启用它:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-shell" data-lang="shell"><span style="display:flex;"><span>net.core.default_qdisc <span style="color:#f92672">=</span> fq
</span></span><span style="display:flex;"><span>net.ipv4.tcp_congestion_control <span style="color:#f92672">=</span> bbr
</span></span></code></pre></div><p>使用 <code>sysctl net.ipv4.tcp_available_congestion_control</code> 查看支持的算法, 用 <code>sysctl net.ipv4.tcp_congestion_control</code> 查看当前使用的算法.</p>
<p>如果这个模块不会自动加载, 需要把 <code>tcp_bbr_powered</code> 添加到 <code>/etc/modules-load.d/modules.conf</code> 中.
另外测试发现, 有时 <code>sysctl.conf</code> 里的设置并不会应用, 需要手动执行一下, 因此便写了 <code>reload-sysctl.service</code> 来做这个, <code>systemctl enable</code> 这个服务后, 一切就 OK 了.</p>
<h2 id="使用增强版">使用增强版</h2>
<p>个人电脑不建议使用增强版, 服务器上可以使用, 当然最终还是要根据两者的效果来选择.</p>
<p>来源于: <a href="https://moeclub.org/2017/06/24/278/">Debian/Ubuntu TCP BBR 改进版/增强版</a></p>
<ul>
<li>Build</li>
</ul>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-shell" data-lang="shell"><span style="display:flex;"><span>$ ./build.sh
</span></span></code></pre></div><ul>
<li>Install</li>
</ul>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-shell" data-lang="shell"><span style="display:flex;"><span>$ ./install.sh
</span></span></code></pre></div><ul>
<li>Clean</li>
</ul>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-shell" data-lang="shell"><span style="display:flex;"><span>$ rm Makefile tcp_bbr_powered.*
</span></span></code></pre></div><p>使用 <code>sysctl net.ipv4.tcp_available_congestion_control</code> 查看支持的算法, 用 <code>sysctl net.ipv4.tcp_congestion_control</code> 查看当前使用的算法.</p>
<p>如果这个模块不会自动加载, 需要把 <code>tcp_bbr_powered</code> 添加到 <code>/etc/modules-load.d/modules.conf</code> 中.
另外测试发现, 有时 <code>sysctl.conf</code> 里的设置并不会应用, 需要手动执行一下, 因此便写了 <code>reload-sysctl.service</code> 来做这个, <code>systemctl enable</code> 这个服务后, 一切就 OK 了.</p>
<h2 id="附件">附件</h2>
<ul>
<li>build.sh</li>
</ul>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-shell" data-lang="shell"><span style="display:flex;"><span>wget --no-check-certificate -qO- <span style="color:#e6db74">&#39;https://moeclub.org/attachment/LinuxSoftware/bbr/tcp_bbr_powered.c.deb&#39;</span> &gt;./tcp_bbr_powered.c
</span></span><span style="display:flex;"><span>echo <span style="color:#e6db74">&#39;obj-m:=tcp_bbr_powered.o&#39;</span> &gt;./Makefile
</span></span><span style="display:flex;"><span>echo <span style="color:#e6db74">&#39;clean: &#39;</span> &gt;&gt; ./Makefile
</span></span><span style="display:flex;"><span>echo -e <span style="color:#e6db74">&#39;\trm -r Module.symvers modules.order tcp_bbr_powered.mod.* tcp_bbr_powered.o .tcp_bbr_powered.* .tmp_versions&#39;</span> &gt;&gt; ./Makefile
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>make -s -C /lib/modules/<span style="color:#66d9ef">$(</span>uname -r<span style="color:#66d9ef">)</span>/build M<span style="color:#f92672">=</span><span style="color:#e6db74">`</span>pwd<span style="color:#e6db74">`</span> modules CC<span style="color:#f92672">=</span><span style="color:#e6db74">`</span>which gcc<span style="color:#e6db74">`</span>
</span></span><span style="display:flex;"><span>make clean
</span></span></code></pre></div><ul>
<li>install.sh</li>
</ul>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-shell" data-lang="shell"><span style="display:flex;"><span><span style="color:#f92672">[</span> -f ./tcp_bbr_powered.ko <span style="color:#f92672">]</span> <span style="color:#f92672">&amp;&amp;</span> <span style="color:#f92672">[</span> -f /lib/modules/<span style="color:#66d9ef">$(</span>uname -r<span style="color:#66d9ef">)</span>/modules.dep <span style="color:#f92672">]</span> <span style="color:#f92672">&amp;&amp;</span> <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>cp -rf ./tcp_bbr_powered.ko /lib/modules/<span style="color:#66d9ef">$(</span>uname -r<span style="color:#66d9ef">)</span>/kernel/net/ipv4
</span></span><span style="display:flex;"><span>depmod -a &gt;/dev/null 2&gt;&amp;<span style="color:#ae81ff">1</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># configure</span>
</span></span><span style="display:flex;"><span>modprobe tcp_bbr_powered
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span> ! -f /etc/sysctl.conf <span style="color:#f92672">]</span> <span style="color:#f92672">&amp;&amp;</span> touch /etc/sysctl.conf
</span></span><span style="display:flex;"><span>sed -i <span style="color:#e6db74">&#39;/net.core.default_qdisc.*/d&#39;</span> /etc/sysctl.conf
</span></span><span style="display:flex;"><span>sed -i <span style="color:#e6db74">&#39;/net.ipv4.tcp_congestion_control.*/d&#39;</span> /etc/sysctl.conf
</span></span><span style="display:flex;"><span>echo <span style="color:#e6db74">&#34;net.core.default_qdisc = fq&#34;</span> &gt;&gt;/etc/sysctl.conf
</span></span><span style="display:flex;"><span>echo <span style="color:#e6db74">&#34;net.ipv4.tcp_congestion_control = bbr_powered&#34;</span> &gt;&gt;/etc/sysctl.conf
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>lsmod |grep -q <span style="color:#e6db74">&#39;bbr_powered&#39;</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span> $? -eq <span style="color:#e6db74">&#39;0&#39;</span> <span style="color:#f92672">]</span> <span style="color:#f92672">&amp;&amp;</span> <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>sysctl -p &gt;/dev/null 2&gt;&amp;<span style="color:#ae81ff">1</span>
</span></span><span style="display:flex;"><span>echo <span style="color:#e6db74">&#34;Finish! &#34;</span>
</span></span><span style="display:flex;"><span>exit <span style="color:#ae81ff">0</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span> <span style="color:#f92672">||</span> <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>echo <span style="color:#e6db74">&#34;Error, Loading BBR POWERED.&#34;</span>
</span></span><span style="display:flex;"><span>exit <span style="color:#ae81ff">1</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><ul>
<li>reload-sysctl.service</li>
</ul>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-shell" data-lang="shell"><span style="display:flex;"><span><span style="color:#f92672">[</span>Unit<span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span>Description<span style="color:#f92672">=</span>Reload sysctl
</span></span><span style="display:flex;"><span>Before<span style="color:#f92672">=</span>network.target
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>Service<span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span>Type<span style="color:#f92672">=</span>simple
</span></span><span style="display:flex;"><span>ExecStart<span style="color:#f92672">=</span>/usr/bin/sysctl -p
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>Install<span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span>WantedBy<span style="color:#f92672">=</span>multi-user.target
</span></span></code></pre></div><ul class="pa0">
  
   <li class="list di">
     <a href="/tags/bbr" class="link f5 grow no-underline br-pill ba ph3 pv2 mb2 dib black sans-serif">bbr</a>
   </li>
  
</ul>
<div class="mt6 instapaper_ignoref">
      
      
      </div>
    </div>

    <aside class="w-30-l mt6-l">




</aside>

  </article>

    </main>
    <footer class="bg-black bottom-0 w-100 pa3" role="contentinfo">
  <div class="flex justify-between">
  <a class="f4 fw4 hover-white no-underline white-70 dn dib-ns pv2 ph3" href="https://jouyouyun.github.io" >
    &copy;  jouyouyun 2023 
  </a>
    <div>
<div class="ananke-socials">
  
    <a href="https://github.com/jouyouyun" target="_blank" class="github ananke-social-link link-transition stackoverflow link dib z-999 pt3 pt0-l mr1" title="GitHub link" rel="noopener" aria-label="follow on GitHub——Opens in a new window">
      
        <span class="icon"><svg style="enable-background:new 0 0 512 512;" version="1.1" viewBox="0 0 512 512"  xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" >
  <path d="M256,32C132.3,32,32,134.8,32,261.7c0,101.5,64.2,187.5,153.2,217.9c11.2,2.1,15.3-5,15.3-11.1   c0-5.5-0.2-19.9-0.3-39.1c-62.3,13.9-75.5-30.8-75.5-30.8c-10.2-26.5-24.9-33.6-24.9-33.6c-20.3-14.3,1.5-14,1.5-14   c22.5,1.6,34.3,23.7,34.3,23.7c20,35.1,52.4,25,65.2,19.1c2-14.8,7.8-25,14.2-30.7c-49.7-5.8-102-25.5-102-113.5   c0-25.1,8.7-45.6,23-61.6c-2.3-5.8-10-29.2,2.2-60.8c0,0,18.8-6.2,61.6,23.5c17.9-5.1,37-7.6,56.1-7.7c19,0.1,38.2,2.6,56.1,7.7   c42.8-29.7,61.5-23.5,61.5-23.5c12.2,31.6,4.5,55,2.2,60.8c14.3,16.1,23,36.6,23,61.6c0,88.2-52.4,107.6-102.3,113.3   c8,7.1,15.2,21.1,15.2,42.5c0,30.7-0.3,55.5-0.3,63c0,6.1,4,13.3,15.4,11C415.9,449.1,480,363.1,480,261.7   C480,134.8,379.7,32,256,32z"/>
</svg>
</span>
      
<span class="new-window"><svg  height="8px"  style="enable-background:new 0 0 1000 1000;" version="1.1" viewBox="0 0 1000 1000"  xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" >
<path d="M598 128h298v298h-86v-152l-418 418-60-60 418-418h-152v-86zM810 810v-298h86v298c0 46-40 86-86 86h-596c-48 0-86-40-86-86v-596c0-46 38-86 86-86h298v86h-298v596h596z" style="fill-rule:evenodd;clip-rule:evenodd;"/>
</svg>
</span></a>
  
</div>
</div>
  </div>
</footer>

  </body>
</html>
